<template>
  <div style="padding:40px;">
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-form-item>
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="form.date1"
            style="width: 100%;">
          </el-date-picker>
      </el-form-item>
      <el-form-item class="line">~</el-form-item>
      <el-form-item>
        <el-date-picker
          type="date"
          placeholder="选择日期"
          v-model="form.date2"
          style="width: 100%;">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="selectResetBillInfo">查询</el-button>
        <el-button @click="onCancel">重置</el-button>
      </el-form-item>
    </el-form>
    <div>
      <el-table
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column
          fixed
          prop="rowIndex"
          label="序号"
          width="50"
          align="center">
          <template slot-scope="scope">
            <span>{{scope.$index+(pageInfo.currentPage - 1) * pageInfo.pageSize + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="escarletBillBatchCode"
          label="红冲票据代码"
          align="center">
        </el-table-column>
        <el-table-column
          prop="escarletBillNo"
          label="红冲电子票据号码"
          align="center">
        </el-table-column>
        <el-table-column
          prop="escarletRandom"
          label="校验码"
          align="center">
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="开具时间"
          align="center">
        </el-table-column>
<!--        <el-table-column-->
<!--          prop="billQRCode"-->
<!--          label="电子票据二维码图片数据"-->
<!--          align="center">-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="pictureUrl"-->
<!--          label="电子票据H5页面URL"-->
<!--          align="center">-->
<!--        </el-table-column>-->
        <el-table-column
          prop="pictureNetUrl"
          label="电子票据外网H5页面URL地址"
          align="center">
        </el-table-column>
        <el-table-column
          prop="operator"
          label="操作人"
          align="center">
        </el-table-column>
        <el-table-column
          prop="loginUser"
          label="登录系统账号"
          align="center">
        </el-table-column>
        <el-table-column
          prop="info"
          label="详细信息"
          align="center">
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageInfo.currentPage"
        :page-sizes="[5, 10, 20, 50]"
        :page-size="pageInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalNumber"></el-pagination>
    </div>

  </div>
</template>
<script>
  import {postAction} from "@/api/manage";
  import moment from 'moment'

  export default {
  name: 'ResetBillForm',
  data() {
    return {
      //分页
      pageInfo: {
        currentPage: 1,
        pageSize: 5
        // pageTotal: 0
      },
      tableData: [],
      totalNumber:0,  //总条数
      value1: '',
      form: {
        date1: '',
        date2: ''
      },
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      url:{
        getResetBillRecord: '/nmyx/leantech/redOffset-list' //红冲票据记录
      }
    }
  },
  created() {
    // this.pageInfo.pageTotal = this.tableData.length;
  },
  methods: {
    selectResetBillInfo(){
      debugger
      var pageSize = this.pageInfo.pageSize
      var pageNum = this.pageInfo.currentPage
      var beginTime = ''
      var endTime = ''
      var t1 = this.form.date1
      var t2 = this.form.date2
      if ('' != t1) {
        beginTime = t1.getFullYear() + '-' + (t1.getMonth() +1) + '-' + t1.getDate()
      }
      if ('' != t2) {
        endTime = t2.getFullYear() + '-' + (t2.getMonth() +1) + '-' + t2.getDate()
      }
      console.log("starttime",beginTime)
      var params = {
        pageNum,pageSize,beginTime,endTime
      }
      // console.log('sizzze',size)
      postAction(this.url.getResetBillRecord,params).then(res =>{
        // debugger
        console.log("ressssss",res)
        if (res.code == 'SUCCESS') {
          this.tableData = res.data.redOffsetBillVoList
          this.totalNumber = res.data.total
        } else {
          alert(res.message)
        }
        console.log('response',res)
      }).catch(err =>{
        window.alert(err)
      })
    },
    onSubmit() {
      this.$message('submit!')
    },
    onCancel() {
      this.$message({
        message: '重置成功',
        type: 'warning'
      })
      this.tableData = []
      this.totalNumber = 0
      this.pageInfo.currentPage = 1
      this.pageInfo.pageSize = 5
    },
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.selectResetBillInfo()
    },
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val;
      this.selectResetBillInfo()
    },
  }
}
</script>

<style scoped>
  .line{
    text-align: center;
  }
</style>
